package org.example.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;

@RestController
@RequestMapping("/transfer")
public class TransferController {
    /**
     * 转账接口
     * @param no   卡号
     * @param name 向谁转账
     * @param fee  转账金额
     * @return
     */
    @PostMapping
    public String transfer(String no, String name, BigDecimal fee) {
        System.out.println(String.format("name: %s, no: %s, fee: %s", no, name, fee));
        return "success";
    }

    public void dynamicSubmitForm(HttpServletResponse response) throws IOException {
        String v = "765555356777";
        String html = "<html><body><form action=\"transfer\"><input name=\"_d\" value=\"" + v + "\"></form></body><html>";
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write(html);
    }
}
